import 'package:PollOnLine/values/MyColors.dart';
import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../r.dart';
import 'my_logic.dart';

class MyPage extends StatefulWidget {
  final String title;

  const MyPage({Key? key, required this.title}) : super(key: key);

  @override
  State<MyPage> createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> {
  final logic = Get.put(MyLogic());
  final state = Get.find<MyLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MyLogic>(builder: (logic) {
      return Scaffold(
        backgroundColor: MyColors.FFEDF1F5,
        body: Stack(
          children: [
            Image.asset(R.assetsImgBgMy1, fit: BoxFit.fitWidth),
            Column(
              children: [
                SafeArea(
                  child: Container(
                    margin: EdgeInsets.only(right: 16.r, top: 10.r),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        InkWell(
                          onTap: () {},
                          child: Stack(
                            alignment: Alignment.topRight,
                            children: [
                              Container(
                                alignment: Alignment.bottomLeft,
                                width: 18.5.r,
                                child: Image.asset(R.assetsImgIconMy2, height: 19.r),
                              ),
                              Container(
                                width: 8.r,
                                height: 8.r,
                                decoration: BoxDecoration(color: MyColors.FFE93232, borderRadius: BorderRadius.circular(10.r)),
                              )
                            ],
                          ),
                        ),
                        Padding(
                          padding: EdgeInsets.only(left: 14.5.r),
                          child: InkWell(
                            onTap: () {
                              logic.goToSet();
                            },
                            child: Image.asset(R.assetsImgIconMy1, width: 18.r),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                Container(
                  height: 61.r,
                  margin: EdgeInsets.only(left: 16.r, right: 16.r, top: 3.r, bottom: 10.r),
                  child: Row(
                    children: [
                      InkWell(
                        onTap: () {},
                        child: Image.asset(R.assetsImgIconHead, width: 61.r),
                      ),
                      Container(
                        margin: EdgeInsets.only(left: 14.5.r, top: 11.r, bottom: 6.r),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            InkWell(
                              onTap: () {},
                              child: Row(
                                children: [
                                  Text(state.userName, style: TextStyle(color: Colors.white, fontSize: 18.r, fontWeight: FontWeight.bold)),
                                  // Padding(padding: EdgeInsets.only(left: 10.r), child: Image.asset(R.assetsImgIconMy6, width: 7.5.r))
                                ],
                              ),
                            ),
                            Row(
                              children: [
                                Visibility(
                                  visible: state.district != "",
                                  child: Container(
                                    height: 15.r,
                                    padding: EdgeInsets.only(left: 4.5.r, right: 4.5.r),
                                    decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.circular(5.75.r),
                                    ),
                                    child: Row(
                                      children: [
                                        Image.asset(R.assetsImgIconMy9, width: 8.5.r),
                                        Padding(
                                          padding: EdgeInsets.only(left: 4.r),
                                          child: Text(state.district, style: TextStyle(color: MyColors.FF333333, fontSize: 10.r)),
                                        )
                                      ],
                                    ),
                                  ),
                                ),
                                Visibility(
                                  visible: state.level != "",
                                  child: Container(
                                    height: 15.r,
                                    margin: EdgeInsets.only(left: 5.r),
                                    padding: EdgeInsets.only(left: 4.5.r, right: 4.5.r),
                                    decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.circular(5.75.r),
                                    ),
                                    child: Row(
                                      children: [
                                        Image.asset(R.assetsImgIconMy10, width: 11.5.r),
                                        Padding(
                                          padding: EdgeInsets.only(left: 4.r),
                                          child: Text(state.level, style: TextStyle(color: MyColors.FF333333, fontSize: 10.r)),
                                        )
                                      ],
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
                Expanded(
                  child: SingleChildScrollView(
                    child: Column(
                      children: [
                        Container(
                          margin: EdgeInsets.only(left: 16.r, right: 16.r, top: 11.r),
                          child: BrnShadowCard(
                            color: Colors.white,
                            circular: 6.r,
                            spreadRadius: 0.11.r,
                            blurRadius: 0.4.r,
                            child: Container(
                              height: 73.5.r,
                              padding: EdgeInsets.only(top: 14.r, bottom: 14.r, left: 0.r, right: 0.r),
                              decoration: BoxDecoration(
                                  gradient: const LinearGradient(
                                    colors: [MyColors.FFD5ECFD, Colors.white],
                                    begin: Alignment.topCenter,
                                    end: Alignment.bottomCenter,
                                  ),
                                  borderRadius: BorderRadius.circular(6.r)),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceAround,
                                children: [
                                  SizedBox(
                                    child: Column(
                                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text("${state.taskNum}",
                                            style: TextStyle(color: MyColors.FF333333, fontSize: 18.r, fontWeight: FontWeight.bold)),
                                        Text("调查任务", style: TextStyle(color: MyColors.FF333333, fontSize: 13.r)),
                                      ],
                                    ),
                                  ),
                                  SizedBox(height: 43.5.r, child: VerticalDivider(color: MyColors.FFD0D0D0, width: 0.5.r)),
                                  SizedBox(
                                    child: Column(
                                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text("${state.score}",
                                            style: TextStyle(color: MyColors.FF333333, fontSize: 18.r, fontWeight: FontWeight.bold)),
                                        Text("考试得分", style: TextStyle(color: MyColors.FF333333, fontSize: 13.r)),
                                      ],
                                    ),
                                  ),
                                  SizedBox(height: 43.5.r, child: VerticalDivider(color: MyColors.FFD0D0D0, width: 0.5.r)),
                                  SizedBox(
                                    child: Column(
                                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text("${state.ranking}",
                                            style: TextStyle(color: MyColors.FF333333, fontSize: 18.r, fontWeight: FontWeight.bold)),
                                        Text("综合排名", style: TextStyle(color: MyColors.FF333333, fontSize: 13.r)),
                                      ],
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ),
                        Container(
                          margin: EdgeInsets.only(left: 16.r, right: 16.r, top: 10.r),
                          child: BrnShadowCard(
                            color: Colors.white,
                            circular: 6.r,
                            spreadRadius: 0.11.r,
                            blurRadius: 0.4.r,
                            child: Container(
                              height: 103.5.r,
                              padding: EdgeInsets.only(left: 15.r, right: 15.r),
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                children: [
                                  InkWell(
                                    onTap: () {},
                                    child: Padding(
                                      padding: EdgeInsets.only(top: 8.r, bottom: 8.r),
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        children: [
                                          Row(
                                            children: [
                                              Image.asset(R.assetsImgIconMy3, width: 15.r),
                                              Padding(
                                                padding: EdgeInsets.only(left: 9.5.r),
                                                child: Text("我的培训", style: TextStyle(color: MyColors.FF333333, fontSize: 14.r,)),
                                              ),
                                            ],
                                          ),
                                          Image.asset(R.assetsImgIconMy5, width: 5.5.r),
                                        ],
                                      ),
                                    ),
                                  ),
                                  Divider(color: MyColors.FFD0D0D0, height: 0.5.r),
                                  InkWell(
                                    onTap: () {},
                                    child: Padding(
                                      padding: EdgeInsets.only(top: 8.r, bottom: 8.r),
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        children: [
                                          Row(
                                            children: [
                                              Image.asset(R.assetsImgIconMy4, width: 15.r),
                                              Padding(
                                                padding: EdgeInsets.only(left: 9.5.r),
                                                child: Text("我的考试", style: TextStyle(color: MyColors.FF333333, fontSize: 14.r)),
                                              ),
                                            ],
                                          ),
                                          Image.asset(R.assetsImgIconMy5, width: 5.5.r),
                                        ],
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ),
                        Container(
                          margin: EdgeInsets.only(left: 16.r, right: 16.r, top: 10.r),
                          child: BrnShadowCard(
                            color: Colors.white,
                            circular: 6.r,
                            spreadRadius: 0.11.r,
                            blurRadius: 0.4.r,
                            child: Container(
                              height: 103.5.r,
                              padding: EdgeInsets.only(left: 15.r, right: 15.r),
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                children: [
                                  InkWell(
                                    onTap: () {},
                                    child: Padding(
                                      padding: EdgeInsets.only(top: 8.r, bottom: 8.r),
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        children: [
                                          Row(
                                            children: [
                                              Image.asset(R.assetsImgIconMy7, width: 15.r),
                                              Padding(
                                                padding: EdgeInsets.only(left: 9.5.r),
                                                child: Text("我的评论", style: TextStyle(color: MyColors.FF333333, fontSize: 14.r)),
                                              ),
                                            ],
                                          ),
                                          Image.asset(R.assetsImgIconMy5, width: 5.5.r),
                                        ],
                                      ),
                                    ),
                                  ),
                                  Divider(color: MyColors.FFD0D0D0, height: 0.5.r),
                                  InkWell(
                                    onTap: () {},
                                    child: Padding(
                                      padding: EdgeInsets.only(top: 8.r, bottom: 8.r),
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        children: [
                                          Row(
                                            children: [
                                              Image.asset(R.assetsImgIconMy8, width: 15.r),
                                              Padding(
                                                padding: EdgeInsets.only(left: 9.5.r),
                                                child: Text("我的收藏", style: TextStyle(color: MyColors.FF333333, fontSize: 14.r)),
                                              ),
                                            ],
                                          ),
                                          Image.asset(R.assetsImgIconMy5, width: 5.5.r),
                                        ],
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ),
                        Container(
                          margin: EdgeInsets.only(left: 16.r, right: 16.r, top: 10.r, bottom: 10.r),
                          child: BrnShadowCard(
                            color: Colors.white,
                            circular: 6.r,
                            spreadRadius: 0.11.r,
                            blurRadius: 0.4.r,
                            child: Container(
                              height: 52.r,
                              padding: EdgeInsets.only(left: 15.r, right: 15.r, top: 8.r, bottom: 8.r),
                              child: InkWell(
                                onTap: () {},
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Row(
                                      children: [
                                        Image.asset(R.assetsImgIconMy11, width: 15.r),
                                        Padding(
                                          padding: EdgeInsets.only(left: 9.5.r),
                                          child: Text("意见反馈", style: TextStyle(color: MyColors.FF333333, fontSize: 14.r)),
                                        ),
                                      ],
                                    ),
                                    Image.asset(R.assetsImgIconMy5, width: 5.5.r),
                                  ],
                                ),
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      );
    });
  }

  @override
  void dispose() {
    Get.delete<MyLogic>();
    super.dispose();
  }
}
